﻿/*
 * Copyright (C) 2010 Proxy Switch <http://proxyswitch.googlecode.com/>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

using System;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProxySwitch
{
    public partial class About : Form
    {
        // declaire CPUArchType string
        string CPUArchType;

        public About()
        {
            InitializeComponent();
        }

        private void AboutLogoTextBox_Click(object sender, EventArgs e)
        {
            try
            {
                // close AboutWindow
                this.Close();
                // goto website
                System.Diagnostics.Process.Start("http://code.google.com/p/proxyswitch/");
            }
            catch (System.Exception ErrorCode)
            {
                // catch the error output to MessageBox
                MessageBox.Show(ErrorCode.Message, "Oh dear!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void About_Load(object sender, EventArgs e)
        {
            // here we display build info to help support
            Version BuildVersion = new Version(Application.ProductVersion);
            CPUArchType = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
            // output to label
            // if application is ported to other platforms _Win_
            // will be replaced with a correct way of pulling OS
            // Maybe support for Mac OS X in the future
            BuildInfo.Text = ("Build Info: ProxySwitch" + "_v" + BuildVersion.Major + "." + BuildVersion.Minor + "_Win_" + CPUArchType + "_r" + BuildVersion.Revision);
        }

        private void WebsiteLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                // close AboutWindow
                this.Close();
                // show licence
                System.Diagnostics.Process.Start("http://www.gnu.org/licenses/gpl-2.0.txt");
            }
            catch (System.Exception ErrorCode)
            {
                // catch the error output to MessageBox
                MessageBox.Show(ErrorCode.Message, "Oh dear!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
